﻿using Microsoft.AspNetCore.Mvc;
using PowerHub.MES.Common.Utility;
using PowerHub.MES.DTO.ProductPlanning.DTO;
using PowerHub.MES.DTO.ProductPlanning.QueryDTO;
using PowerHub.MES.Entities.ProductPlanning;
using PowerHub.MES.IServices.IProductPlanning;
using PowerHub.MES.ReturnEntity;

namespace PowerHub.MES.Controllers.ProductPlanning
{
    /// <summary>
    /// 原料
    /// </summary>
    [ApiController]
    [Route("Api/MES/ProductPlanning/[controller]/[action]")]
    public class MaterialController
    {

        private IProductPlanning_MaterialServices _ProductPlanning_MaterialServices;

        public MaterialController(IProductPlanning_MaterialServices MaterialServices)
        {
            _ProductPlanning_MaterialServices = MaterialServices;
        }

        /// <summary>
        /// 获取原料列表
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        [HttpPost]
        [FunctionDescription("获取原料列表")]
        public async Task<OperationPageResult<List<ProductPlanning_Material>>> GetProductPlanning_MaterialPageListAsync([FromBody] QueryProductPlanning_MaterialDTO pageQuery)
        {
            return await _ProductPlanning_MaterialServices.GetProductPlanning_MaterialPageListAsync(pageQuery);
        }


        /// <summary>
        /// 批量删除原料
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        [HttpPost]
        [FunctionDescription("批量删除原料")]
        public async Task<OperationResult<object>> DeletionProductPlanning_MaterialAsync([FromBody] List<string> Query)
        {
            return await _ProductPlanning_MaterialServices.DeletionProductPlanning_MaterialAsync(Query);
        }

        /// <summary>
        /// 更新原料
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        [HttpPost]
        [FunctionDescription("更新原料")]
        public async Task<OperationResult<object>> UpdateProductPlanning_MaterialAsync([FromBody] ProductPlanning_MaterialDTO Query)
        {
            return await _ProductPlanning_MaterialServices.UpdateProductPlanning_MaterialAsync(Query);
        }

        /// <summary>
        /// 添加原料
        /// </summary>
        /// <returns></returns>
        /// <exception cref="Exception"></exception>
        [HttpPost]
        [FunctionDescription("添加原料")]
        public async Task<OperationResult<object>> CreateProductPlanning_MaterialAsync([FromBody] ProductPlanning_MaterialDTO Query)
        {
            return await _ProductPlanning_MaterialServices.CreateProductPlanning_MaterialAsync(Query);
        }
    }
}
